package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.SupplierContactUserEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/24 15:44
 * @since v1.0
 */

public interface SupplierContactUserModel extends IModel<SupplierContactUserEntity> {

    /**
     * 保存实体
     *
     * @param SupplierContactUserEntity 联系人协同人团队实体
     * @return java.lang.Integer
     * @throws XbbException 数据库异常
     * @author feng.zheng
     * @date 2019/2/14 16:42
     */
    Integer save(SupplierContactUserEntity SupplierContactUserEntity) throws XbbException;

    /**
     * 获取单个实体
     *
     * @param key    id主键
     * @param corpid 公司id
     * @return com.xbongbong.saas.domain.entity.SupplierContactUserEntity
     * @author feng.zheng
     * @date 2019/2/14 16:43
     */
    SupplierContactUserEntity getByKey(Long key, String corpid);



    /**
     * 获取符合查询条件的记录
     *
     * @param param 查询条件
     * @return 符合查询条件的记录
     */
    @Override
    List<SupplierContactUserEntity> findEntitys(Map<String, Object> param);

    void insetBatch(List<SupplierContactUserEntity> supplierContactUserEntityList) throws XbbException;

    void delete(SupplierContactUserEntity supplierContactUserEntity) throws XbbException;

    void insetBatch(List<SupplierContactUserEntity> supplierContactUserEntityList, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    List<UserTeamEntity> findBaseEntitys(Map<String,Object> map);

    Integer deleteBatchBySupplierAndContact(Long supplierId, Long contactId, String corpid) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    List<SupplierContactUserEntity> getBySupplierId(String corpid, Long supplierId, Integer del);

    List<SupplierContactUserEntity> getBySupplierId(String corpid, Long supplierId);
    /**
     * 批量删除
     *
     * @param list 更新的数据id
     * @param corpid 公司id
     * @param del
     * @return 是否成功
     * @throws XbbException 异常
     */
    void deleteBatchUser(List<SupplierContactUserEntity> list, String corpid, Integer del) throws XbbException;

    void updateBatch(List<SupplierContactUserEntity> supplierContactUserEntities, String corpid) throws XbbException;

    void deleteByDataIds(List<Long> dataIds, String corpid) throws XbbException;

    /**
     * 编辑团队成员标签
     *
     * @param supplierContactUserEntity
     */
    void editLabel(SupplierContactUserEntity supplierContactUserEntity) throws XbbException;

    /**
     * 更新协同人可编辑权限
     *
     * @param supplierContactUserEntity
     */
    void updateEditFormPer(SupplierContactUserEntity supplierContactUserEntity) throws XbbException;

    /**
     * 更新团队协同人信息和协同人可编辑权限
     *
     * @param corpid
     * @param idIn
     * @param updateUserToCoTeamList
     * @param coopUser
     * @param needThrow
     */
    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> updateUserToCoTeamList, Integer coopUser, boolean needThrow) throws XbbException;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;
}


